package com.hdu.seckilldemo.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//RabbitMq配置类，direct模式
//@Configuration
public class RabbitMQConfigDirect {
    private static final String QUEUE_DIRECT_01 = "queue_direct01";
    private static final String QUEUE_DIRECT_02 = "queue_direct02";
    private static final String EXCHANGE = "directExchange";
    private static final String ROUTINGKEY01 = "queue.red";
    private static final String ROUTINGKEY02 = "queue.green";

    @Bean
    public Queue queue_direct_01(){
        return new Queue(QUEUE_DIRECT_01);
    }
    @Bean
    public Queue queue_direct_02(){
        return new Queue(QUEUE_DIRECT_02);
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    public Binding binding_direct01(){
        return BindingBuilder.bind(queue_direct_01()).to(directExchange()).with(ROUTINGKEY01);
    }
    @Bean
    public Binding binding_direct02(){
        return BindingBuilder.bind(queue_direct_02()).to(directExchange()).with(ROUTINGKEY02);
    }
}
